<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
    	<div class="col-sm-12 select-info">
			<form id="menu-form">
				<div class="select-list">
					<ul>
						<li class="select-time">
							<label>出库时间： </label>
							<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
							<span>-</span>
							<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
						</li>
						<li>
							物品名称：<input type="text" name="goodsName"/>
						</li>
						
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()" shiro:hasPermission="system:post:export"><i class="fa fa-download"></i>&nbsp;导出</a>
						</li>
					</ul>
				</div>
			</form>
		</div>
		
		<div class="btn-group hidden-xs" id="toolbar" role="group">
			<a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()" shiro:hasPermission="store:outbound:add">
				<i class="fa fa-plus"></i> 新增
			</a>
			<!-- <a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.removeAll()" shiro:hasPermission="store:outbound:remove">
				<i class="fa fa-trash-o"></i> 删除
			</a> -->
		</div>
			
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('store:outbound:edit')}]];
        var removeFlag = [[${@permission.hasPermi('store:outbound:remove')}]];
        var prefix = ctx + "store/outbound"

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "出库单",
                search: false,
		        showExport: false,
                columns: [{
		            checkbox: true
		        },
				/* {
					field : 'outboundId', 
					title : '出库单ID' 
				}, */
				{
					field : 'outboundDate', 
					title : '出库日期' 
				},
				{
					field : 'goodsList.goodsName', 
					title : '物品名称' 
				},
				{
					field : 'outboundNumber', 
					title : '数量' 
				},
				/* {
					field : 'outboundPrice', 
					title : '单价' 
				},
				{
					field : 'outboundMoney', 
					title : '金额' 
				}, */
				{
					field : 'remark', 
					title : '备注' 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.outboundId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="remove(\'' + row.outboundId + '\')"><i class="fa fa-remove">删除</i></a>');
                        return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        function remove(outboundId) {
			$.modal.confirm("确定删除该条" + $.table._option.modalName + "信息吗？", function() {
				$.ajax({
					type : 'post',
					url: prefix + "/remove/" + outboundId,
					success : function(result) {
						if (result.code == web_status.SUCCESS) {
		                	$.modal.msgSuccess(result.msg);
		                	$.table.refresh();
		                } else {
		                	$.modal.msgError(result.msg);
		                }
					}
				});
			});
		}
    </script>
</body>
</html>